const processTemplate = {
  state: {
    workStageTree: [], // 批次，物料，工序三级联动树
    listData: {}, // 工序记录模板列表
    detailInfo: {}, // 工序记录模板详情信息
    detailData: {
      list: []
    }, // 工序记录模板详情列表
  },
  // 唯一拥有更改内存数据的接口，不可进行异步操作
  mutations: {
    setDetailInfo(state, status) {
      if (status) state.detailInfo[status] = ''
    },
    setDetailData(state, arr) {
      state.detailData.list = arr
    },
    addDetailData(state, index) {
      if (state.detailData.list && state.detailData.list.length > 0) {
        state.detailData.list.splice(index + 1, 0, {})
      } else {
        state.detailData.list = [{}]
      }
    },
    deleteDetailData(state, index) {
      if (state.detailData.list && state.detailData.list.length > 1) {
        state.detailData.list.splice(index, 1)
      } else {
        state.detailData.list = [{}]
      }
    }
  },
  // 与mutation通讯，ui层写入内存数据的接口，可异步操作
  actions: {}
}

export default processTemplate
